package com.yuwei.property.view

import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.yuwei.base.BaseActivity
import com.yuwei.base.path.RouterPath
import com.yuwei.property.adapter.TenantAdapter
import com.yuwei.property.databinding.ActivityTenantBinding
import com.yuwei.property.viewmodel.PropertyViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = RouterPath.MODULE_TENANT_ACTIVITY)
class TenantActivity : BaseActivity<ActivityTenantBinding,PropertyViewModel>() {
    private val tenantAdapter = TenantAdapter()
    override fun initView() {
        vm.getTenantList()
        binding.tenantBack.setOnClickListener {
            finish()
        }
        binding.tenantRv.adapter = tenantAdapter
        binding.tenantRv.layoutManager = LinearLayoutManager(this)
    }

    override fun initData() {
        vm.getTenantSuccess.observe(this){
            Log.d("TAG", "initDatattt: ${it.size}")
            tenantAdapter.data.addAll(it)
            tenantAdapter.notifyDataSetChanged()
        }
    }

}